{include file="public/header" /}

<article class="page-container">
    <form action="" method="post" class="form form-horizontal" enctype="multipart/form-data" id="form-add">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">昵称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" placeholder="" value="{$row.name|default=''}" name="name"
                       datatype="*" nullmsg="昵称不能为空">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">前端地址：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" placeholder="" value="{$row.web|default=''}" name="web"
                       datatype="*" nullmsg="前端地址不能为空">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">后台接口：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" placeholder="" value="{$row.url|default=''}" name="url"
                       datatype="*" nullmsg="后台接口不能为空">
            </div>
        </div>
        <div class="row cl" style="width: 100%">
            <div style="width: 100%;text-align: center">
                <input type="hidden" value="{$row.id|default=''}" name="id">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</article>

<!--我在这做了修改，给了一个name属性，方便后端接收值-->

{include file="public/footer" /}
<script>
    $("#form-add").validate({
        rules: {
            username: {
                required: true,
                maxlength: 50
            },
        },
        onkeyup: false,
        focusCleanup: true,
        success: "valid",
        submitHandler: function (form) {
            $(form).ajaxSubmit({
                success: function (data) {
                    console.log(data);
                    if (data.status == 'y') {
                        layer.msg("操作成功", {icon: 1, time: 1000, shade: [0.3, '#000']}, function () {
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.location.reload();
                            parent.layer.close(index);
                        });
                    } else {
                        layer.msg(data.info, {icon: 2, time: 1000, shade: [0.3, '#000']});
                    }
                },
                error: function (error) {
                    layer.msg('系统发生了错误', {icon: 2, time: 3000, shade: [0.5, '#FF0000']});
                }
            });

        }
    });
</script>
